In computer software, a read barrier mechanism may exist for a program object. In this type of operation, the program object is said to be guarded, and any read access to the program object is then trapped or detected.
A read barrier may have many applications in software, including: (1) A read barrier may be used to mediate access to proxies that represent remote objects in distributed object systems. Similarly, read barriers may be used to mediate accesses to persistent objects in persistent object systems. (2) A read barrier may be used to trap accesses to objects that are being garbage collected in runtimes that employ concurrent garbage collection. (3) A read barrier may be used to track references across memory heap regions in runtimes that partition the heap into regions. This may include generational garbage collectors, which partition a heap into generations. (4) A read barrier may be used to implement debug watch points.
If a read barrier has been implemented for a program object, a runtime environment checks each read access to determine whether the access touches a guarded object. However, the process of providing a read barrier may have negative effects on performance. The requirement to provide a check of each read access to determine whether the access is directed to a guarded object may consume considerable computer resources, and thus may impose costs for system operations.